package com.njupt.swg.threadstudyjimin.item06.syncContainer;

import com.njupt.swg.threadstudyjimin.annotation.NotThreadSafe;

import java.util.Vector;

@NotThreadSafe
public class VectorTest {
    private static Vector<Integer> vector = new Vector<>();


    public static void main(String[] args) {
        while(true){

            for(int i=0;i<10;i++){
                vector.add(i);
            }

            Thread t1 = new Thread(){
                @Override
                public void run() {
                    for(int i=0;i<vector.size();i++){
                        vector.remove(i);
                    }
                }
            };

            Thread t2 = new Thread(){
                @Override
                public void run() {
                    for(int i=0;i<vector.size();i++){
                        vector.get(i);
                    }
                }
            };

            t1.start();
            t2.start();
        }
    }
}
